home *** CD-ROM | disk | FTP | other *** search
- /* make the preprocessor jump through a few hoops */
-
- #include <stdio.h>
-
- #define plus(x,y) \
- ((x)+(y))
-
- #define ccat(x,y) x##y
- #define sify(x) #x
- #line 3 "prexy.c"
- #define karma 1
- #define woofma 7
- #pragma dogma
-
- main()
- {
- int a=4,b=5,ab=6;
- puts("hello");
-
- #ifdef woofma
- puts("yep");
- #else
- puts("nope");
- #endif
-
- #ifdef karma
- puts("good karma 1");
- #else
- puts("bad else");
- #endif
-
- #undef woofma
-
- #if karma==2
- puts("bad karma a");
- #elif karma==1
- puts("good karma 2");
- #else
- puts("bad karma e");
- #endif
-
- #ifdef woofma
- puts("nopey");
- #else
- puts("yeah");
- #endif
-
- #ifndef woofma
- puts("yes");
- #else
- puts("noway");
- #endif
-
- // this is a single line comment
-
- printf("%d %d %s %d %s %s\n",
- miracle,msdos,__FILE__,__LINE__,__DATE__,__TIME__);
-
- printf("%d %d %d %s\n",plus(a,b),b,ccat(a,b),sify(a) "yeahok" sify(b));
- }
-